# Contributor: John Proctor <jproctor@prium.net>
# Contributor: Alain Kalker <a.c.kalker@gmail.com>
# Maintainer: Juergen Hoetzel <juergen@archlinux.org>

pkgname=cmucl
pkgver=21b
pkgrel=2
pkgdesc="CMU Common Lisp"
depends_i686=('glibc' 'openmotif')
depends_x86_64=('lib32-glibc' 'openmotif')
provides=('common-lisp')
makedepends=('sed' 'bc')
license=('custom')
#license PublicDomain
source=("https://common-lisp.net/project/cmucl/downloads/release/${pkgver}/cmucl-src-${pkgver}.tar.bz2"
	"https://common-lisp.net/project/cmucl/downloads/release/${pkgver}/cmucl-src-${pkgver}.tar.bz2.asc"
        "https://common-lisp.net/project/cmucl/downloads/release/${pkgver}/cmucl-${pkgver}-x86-linux.tar.bz2"
	"https://common-lisp.net/project/cmucl/downloads/release/${pkgver}/cmucl-${pkgver}-x86-linux.tar.bz2.asc")
sha256sums=('6f9ea5920d38d6881cee85d976565b3a6070bf6473dd64254e0e9f2f23625875'
            'SKIP'
            'eaccb1d676dbf40c5327ae5c61a7a638e4c12525b1e4118535582ffb7c59638e'
            'SKIP')
validpgpkeys=('0EF50ED55514BFF6B72B9DAC06CE3819086C750B') # "Raymond Toy <toy.raymond@gmail.com>
url="https://www.cons.org/cmucl/"
arch=('i686')

prepare() {
  cd "${srcdir}"

  if [[ $CARCH == "i686" ]]; then
    sed -i 's|i386\*|i686\*|' bin/build-all.sh
  fi
}

build() {
  cd "${srcdir}"
  export CMUCLLIB="${srcdir}"/lib/cmucl/lib
  # Build using binary-dist lisp
  ./bin/build-all.sh -o "${srcdir}"/bin/lisp
}

package() {
  cd "${srcdir}"
  # install distribution
  ./bin/make-dist.sh -I "${pkgdir}"/usr -M share/man/man1 linux-4
  # move docs
  mv "${pkgdir}"/usr/doc "${pkgdir}"/usr/share/
  # backwards compatibility
  ln -sf lisp "${pkgdir}"/usr/bin/cmucl
  # license
  install -D -m644 "${srcdir}"/src/general-info/COPYRIGHTS \
                   "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}

